<template>
  <div class="layui-layout layui-layout-admin">
    <div class="adminnav1">
      <Pagetop></Pagetop>
    </div>
    <div class="adminnav2">
      <Secondnav urlname="user"></Secondnav>
    </div>

    <!-- 主体内容 -->
    <div class="layui-body kedou-admin" id="LAY_app_body app">
      <div class="layadmin-tabsbody-item layui-show">
        <div class="pagelist">
          <div class="layui-card-body">
            <fieldset class="layui-elem-field layui-field-title">
              <legend>门店审核</legend>
            </fieldset>
          </div>
          <div class="pagetop">
            <Search :seadate="searchArr"></Search>
          </div>
          <div class="layui-card-body">
            <div class="buttop">
              <button type="button" class="layui-btn  layui-btn-normal" @click="addData">
                添加门店
              </button>
              <!-- <button type="button" class="layui-btn  layui-btn-normal" @click="userdw">
                下载地址
              </button> -->
              <a href="../../../../static/dist.rar" download="dist.rar" type="button"
                class="layui-btn layui-btn-danger"> 小程序源码下载
              </a>
            </div>
            <Tables :fdate="pdate" :result="res" height="430" :totalCount="totalRows" :pageNumber="curindex"
              :fbtn="btn"></Tables>

          </div>

        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Pagetop from "../../common/pagetop.vue";
import Secondnav from "../../common/secondnav.vue";
import Tables from "../../common/tables.vue";
import Search from "../../common/search.vue";
export default {
  name: "userset",
  components: { Pagetop, Secondnav, Tables, Search },
  data () {
    return {
      pdate: [], // 表头
      res: "",//内容
      totalRows: "",//总数量
      curindex: 1,//页数
      btn: [], //按钮
      searchArr: [],//搜索
      isShow: false,
      seapram: "",
    };
  },
  mounted () {
    this.getdate();
    this.getsearch();
  },
  methods: {
    getdate: function () {
      var vm = this;
      var url = "/advert/aapi/v1.9/apply-setting/";
      if (vm.seapram) {
        var dates = {
          size: pageSize,
          page: vm.curindex
        };
        var res = vm.seapram;
        for (var i = 0; i < res.length; i++) {
          dates[res[i].key] = res[i].val;
        }
      } else {
        var dates = {
          size: pageSize,
          page: vm.curindex
        };
      }
      //alert(url+"//"+JSON.stringify(dates))
      ajaxRequest(url, "GET", "json", dates, function (ret, err) {
        // alert(url + "//" + JSON.stringify(ret))
        var arr = [];
        arr[0] = [
          { field: "dealerName", title: "商家名称", }
          , { field: "applyName", title: "应用名称", }
          , {            field: "createAt", title: "创建日期", templet: function (d) {
              return FormatDate(d.createAt, 3);
            }          }
          , {            field: "auditStatus", title: "审核状态", templet: function (d) {
              if (d.auditStatus == "UNAUDITED") return "待审核";
              else if (d.auditStatus == "AUDIT_PASS") return "审核通过";
              else return "审核不通过";
            }          }
          , {            field: "right", title: "操作", width: "120", fixed: "right", templet: function (d) {
              var str = '<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit">审核</a>';
              return str;
            }
          }
        ];
        vm.pdate = arr;
        vm.res = ret.data.list;
        vm.totalRows = ret.data.totalRows;
        vm.curindex = ret.data.page + 1;
      });
    },
    getsearch: function () {
      var arr = [{ field: "id", title: "ID", type: "input" }];
      this.searchArr = arr;
    },
    page: function (index, obj) {
      this.curindex = index;
      this.getdate();
    },
    suosuo: function (pram) {
      this.seapram = pram;
      this.res = "";
      this.totalRows = "";
      this.curindex = 1;
      this.getdate();
    },
    addData: function () {
      layer.open({
        type: 2
        , title: '添加门店'
        , content: baseurl + '/usersetadd'
        , area: ['50%', '60%']
      });
    },
    editInfo: function (data) {
      var vm = this;
      layer.open({
        type: 2,
        title: "审核门店信息",
        content: baseurl + '/usersetem',
        area: vm.screens() < 2 ? ["60%", "88%"] : ["600px", "880px"],
        success: function (layero, index) {
          var ifremeWin = window[layero.find("iframe")[0]["name"]];
          ifremeWin.getdates(data);
        }
      });
    },
    screens: function () {
      return screen();
    }
  },
  updated: function () {
    this.isShow = true;
    layui.use("form", function () {
      var form = layui.form;
      form.render();
    });
  }
};
</script>
<style scoped>
/**/
</style>